import request from '@/utils/request'

//获取联动数据进行展示
export const reqSpuList = (page, limit, category3Id) => request({ url: `/admin/product/${page}/${limit}`, method: "GET", params: { category3Id } })

///admin/product/getSpuById/{spuId}
export const reqSpu = (spuId) => request({ url: `admin/product/getSpuById/${spuId}`, method: 'GET' })

//获取品牌信息
export const reqTradeMarkList = () => request({ url: '/admin/product/baseTrademark/getTrademarkList', method: 'GET' })


//获取图片接口
export const reqSpuImageList = (spuId) => request({ url: `/admin/product/spuImageList/${spuId}`, method: "GET" })


//获取销售属性
export const reqBaseSaleAttrList = () => request({ url: '/admin/product/baseSaleAttrList', method: "GET" })


//修改或者添加spu ，判断是否有没有id即可，有id就是修改，没有就是添加
export const reqAddOrUpdateSpu = (spuInfo) => {
    if (spuInfo.id) {
        return request({ url: '/admin/product/updateSpuInfo', method: 'POST', data: spuInfo })
    } else {
        return request({ url: '/admin/product/saveSpuInfo', method: 'POST', data: spuInfo })
    }
}